<?php

namespace App\model\broker;

use Illuminate\Database\Eloquent\Model;

/**
 * App\model\broker\BrokerRewardRecord
 *
 * @property int $id
 * @property float|null $reward 奖励
 * @property string|null $reward_type
 * @property int|null $to_user_id 用户得到的id
 * @property int|null $from_user_id
 * @property \Illuminate\Support\Carbon|null $created_at
 * @property \Illuminate\Support\Carbon|null $updated_at
 * @method static \Illuminate\Database\Eloquent\Builder|\App\model\broker\BrokerRewardRecord whereCreatedAt($value)
 * @method static \Illuminate\Database\Eloquent\Builder|\App\model\broker\BrokerRewardRecord whereFromUserId($value)
 * @method static \Illuminate\Database\Eloquent\Builder|\App\model\broker\BrokerRewardRecord whereId($value)
 * @method static \Illuminate\Database\Eloquent\Builder|\App\model\broker\BrokerRewardRecord whereReward($value)
 * @method static \Illuminate\Database\Eloquent\Builder|\App\model\broker\BrokerRewardRecord whereRewardType($value)
 * @method static \Illuminate\Database\Eloquent\Builder|\App\model\broker\BrokerRewardRecord whereToUserId($value)
 * @method static \Illuminate\Database\Eloquent\Builder|\App\model\broker\BrokerRewardRecord whereUpdatedAt($value)
 * @mixin \Eloquent
 * @property-read \App\User|null $fromUser
 */
class BrokerRewardRecord extends Model
{
    protected $table='broker_reward_records'; //分享利益表
    const effective_direct='effective_direct';
    const effective_share='effective_share';
    const follow_share='follow_share';
    const follow_direct='follow_direct';
    const transaction_direct='transaction_direct';
    const transaction_share='transaction_share';
    const superior_effective_direct='superior_effective_direct';
    const superior_effective_share='superior_effective_share';
    const superior_follow_share='superior_follow_share';
    const superior_follow_direct='superior_follow_direct';
    const superior_transaction_direct='superior_transaction_direct';
    const superior_transaction_share='superior_transaction_share';

    static $reward_type_map=[
        self::effective_direct=>'有效推荐奖励',
        self::effective_share=>'有效分享朋友圈奖励',
        self::follow_direct=>'继续跟进推荐奖励',
        self::follow_share=>'继续跟进分享朋友圈奖励',
        self::transaction_direct=>'成交推荐奖励',
        self::transaction_share=>'成交分享朋友圈奖励',
        self::superior_effective_direct=>'上级有效推荐奖励',
        self::superior_effective_share=>'上级有效分享朋友圈奖励',
        self::superior_follow_direct=>'上级继续跟进推荐奖励',
        self::superior_follow_share=>'上级继续跟进分享朋友圈奖励',
        self::superior_transaction_direct=>'上级成交推荐奖励',
        self::superior_transaction_share=>'上级成交分享朋友圈奖励',
    ];
    public function fromUser(){
        return $this->belongsTo(\App\user::class,'from_user_id');
    }
}
